<?php
/**
 * Created by PhpStorm.
 * User: s.utkin
 * Date: 02.09.14
 * Time: 20:10
 */

namespace NotificationDelivery\Delivery;

class PushStreamUrlAction extends \Action
{

	/**
	 * Указываем необходимые неявные параметры
	 * @return multitype:string
	 */
	static function pullParams() {
		return ['identity'];
	}
	
    /**
     * Выводит span#subscribeUrl со свойством value, содержащим адрес подписки на pushStream канал
     */
    protected function run()
    {
        $this->response->noRender(true);

        $myProfileId = $this->request->_identity;
        if (!$myProfileId) {
            $this->response->content = '';
            return;
        }

        $pushStream = new PushStream($myProfileId);
        $url = $pushStream->subscribe();
        if (!empty($url)) {
        	$this->response->content = '<span id="subscribeUrl" style="display:none;" value="' . $url. '"></span>';
        }
    }
}